﻿using MaxLeaf.Platform.BLLProxy;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using MaxLeaf.Platform.DataContract;
using Moq;
using MaxLeaf.Platform.Contract;
using MaxLeaf.Platform.BLLImplementation;
using System.Diagnostics;
using System.Collections.Generic;

namespace BLLUnitTest
{
    
    
    /// <summary>
    ///这是 mUser_MainBLLProxyTest 的测试类，旨在
    ///包含所有 mUser_MainBLLProxyTest 单元测试
    ///</summary>
    [TestClass()]
    public class mUser_MainBLLProxyTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///获取或设置测试上下文，上下文提供
        ///有关当前测试运行及其功能的信息。
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region 附加测试特性
        // 
        //编写测试时，还可使用以下特性:
        //
        //使用 ClassInitialize 在运行类中的第一个测试前先运行代码
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //使用 ClassCleanup 在运行完类中的所有测试后再运行代码
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //使用 TestInitialize 在运行每个测试前先运行代码
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //使用 TestCleanup 在运行完每个测试后运行代码
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///Login 的测试
        ///</summary>
        [TestMethod()]
        public void MtnTest()
        {
            //MtnBLLProxy bll = new MtnBLLProxy(); // TODO: 初始化为适当的值

            //mUser_MainDataModel user = (mUser_MainDataModel)bll.Select(new mUser_MainDataModel(), 13);
            //Debug.WriteLine(user);
            //Assert.IsNotNull(user);



            mUser_MainBLLProxy bll = new mUser_MainBLLProxy();
            mUser_MainDataModel user1 =  new mUser_MainBLLProxy().Login("admin5", "123456");
            mUser_MainDataModel user2 =  new mUser_MainBLLProxy().Login("admin5", "123456");
            mUser_MainDataModel user = new mUser_MainDataModel { CompanyID = 1, Name = "admin5", PassWord = "123456" };
            user = (mUser_MainDataModel)new MtnBLLProxy().Add(user);
            Assert.IsNotNull(user);
            //Assert.IsNotNull(user.Sub_Company);
            //Assert.AreNotEqual<int>(0, user.Key);
            //user = bll.Login("admin5", "123456");
            //Assert.IsNotNull(user);

            //user = (mUser_MainDataModel)new MtnBLLProxy().Select(new mUser_MainDataModel(), user.Key);
            //Assert.IsNotNull(user);

            //List<object> lst = new MtnBLLProxy().SelectByCond(new mUser_MainDataModel()
            //         , new List<AddInfo>() { 
            //             new AddInfo{Name= AddInfoType.Cond,Value=  new List<Cond> {
            //                                                        new Cond{ Name="UserName",Compare=CompareType.Greater , Value ="a"}
            //                                                        ,new Cond{ Name="UserName",Compare= CompareType.LessEqual , Value ="b"}
            //                                                    }
            //             }
            //             ,new AddInfo{Name= AddInfoType.SortBy ,Value= new List<SortBy> { new SortBy { Name = "Recid", DESC = true } }}
            //         } 
            //).Data;
            //Assert.IsNull(lst);
        }
    }
}
